package io.renren.modules.edu.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class IdNumberUtils {
    public static boolean check(String str) {
        String patt= "";
        if(str.length()==15)
            patt="^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$";
        else if(str.length()==18)
            patt="^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
        else
            return false;
        Pattern r = Pattern.compile(patt);
        Matcher matcher = r.matcher(str);
        return matcher.find();
    }
}
